import Vue from 'vue'
import Router from 'vue-router'
import Main from '../views/Main'
import Index from '../views/main/Index'
import Message from '../views/main/Message'
import Cart from '../views/main/Cart'
import User from '../views/main/User'
import SearchList from '../views/SearchList'
import ItemDetail from '../views/ItemDetail'
import Chat from '../views/Chat'
import Order from '../views/Order'
import ErrorPage from '../views/ErrorPage'

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: '/vue-shop/',
  routes: [
    {
      path: '',
      redirect: 'index'
    },
    {
      path: '/main',
      name: 'Main',
      component: Main,
      children: [
        {
          path: '/index',
          name: 'Index',
          component: Index
        },
        {
          path: '/message',
          name: 'Message',
          component: Message
        },
        {
          path: '/cart',
          name: 'Cart',
          component: Cart
        },
        {
          path: '/user',
          name: 'User',
          component: User
        }
      ]
    },
    {
      path: '/searchList',
      name: 'SearchList',
      component: SearchList
    },
    {
      path: '/itemDetail',
      name: 'ItemDetail',
      component: ItemDetail
    },
    {
      path: '/chat',
      name: 'Chat',
      component: Chat
    },
    {
      path: '/order',
      name: 'Order',
      component: Order
    },

    // 跳转到404页面
    {
      path: '*',
      name: 'Error',
      component: ErrorPage
    }
  ]
})
